<?
include("../header.php");
?>
<script type="text/javascript">
	function hapus(Cat,NIK,No)
	{
		var ok = confirm("Apakah Anda yakin menghapus data tersebut ?");
		if(ok == true)
		{
			window.location.href="delete.php?cat="+ Cat +"&nik="+ NIK +"&no="+No+"";
		}
		else
		{
		}
	}
	
	function konfirm(Cat,ID,NIK)
	{
		var ok = confirm("Apakah Anda akan menyetujui data tersebut data tersebut ?");
		if(ok == true)
		{
			window.location.href="<?=$PHP_SELF?>?show=list_track_record&appr=yes&cat2="+ Cat +"&no="+ ID +"&nik="+ NIK +"";
		}
		else
		{
		}
	}	
	
</script>
</head>
<?
include("config.php");
$nik	= $HTTP_GET_VARS['nik'];
$show	= $HTTP_GET_VARS['show'];
$op		= $HTTP_GET_VARS['op'];
$no		= $HTTP_GET_VARS['no'];

$sqlH	= mssql_query("SELECT * FROM VKarirPTSI WHERE NIK='$nik' ",$conn);
$rowH	= mssql_fetch_array($sqlH);


	if($show == "list_karir")
	{
// untuk hak akses
	$spar = mssql_query("SELECT * FROM VPrivUser WHERE username='".$_SESSION['user_login']."' AND nama_menu='karir_ptsi'",$conn);
	$rpar = mssql_fetch_array($spar);	
	
?>  
<table width=100% class='table_indent2'>
</table>
<table cellspacing="1" width="100%">
   <tr>
   <td colspan="10">
   <table>
   <tr>
    <td width="50">NIK</td>
	<td colspan="9"><?=$rowH[NIK]?></td>
   </tr>
   <tr>
    <td>Nama</td>
	<td colspan="9"><?=$rowH[Nama]?></td>
   </tr>
   </table>
   </td>
   </tr>
   <tr>
    <td colspan="10" align="right">
    <?
    if($rpar[tambah] == 1){
	?>
    <input type="button" class="button" value="Tambah" onclick="Javascript:location.href='../form/frm_karir_ptsi.php?nik=<?=$rowH[NIK]?>&amp;nama=<?=$rowH[Nama]?>'"/>
    <?
    }
	?>
    </td>
   </tr>
   <tr>
    <td colspan="10"><hr noshade="noshade" size="-2" /></td>
   </tr>
   <tr class="headlist">
    <td width="1%">No.</td>
	<td>No. Surat</td>
	<td>Jenis Surat</td>
	<td>Tanggal Efektif</td>
	<td>Tanggal SKD</td>
	<td>Unit Kerja</td>
	<td>Jabatan</td>
	<td>Fungsional</td>
    <td>Gol</td>
    <td>Status</td>
	<td colspan="2">&nbsp;</td>
   </tr>
<?
$sql	= mssql_query("SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, CONVERT(CHAR(12), tgl_efektif, 103) TglEfektif, CONVERT(CHAR(12), tgl_skd, 103) TglSkd, * FROM VKarirPTSI WHERE NIK='$nik' ORDER BY seqno",$conn);
while($row = mssql_fetch_array($sql)){
	echo"
	<tr class=contentlist>
	 <td align=right><small>$row[No]</td>
	 <td><small>$row[no_surat]</td>
	 <td>";
	// get jenis surat
	$sgetjns = mssql_query("SELECT * FROM VJenisSurat WHERE IDCode='$row[Jenis]'",$conn);
	if($sgetjns){
		$rgetjns = mssql_fetch_array($sgetjns);
	}
	echo"<small>$rgetjns[nama]";
	echo"</td>	 
	 <td align=right><small>$row[TglEfektif]</td>	 
	 <td align=right><small>$row[TglSkd]</td>	 
	 <td>";
		$kodeso = $row[kode_so2];
	if(trim($kodeso)== ""){
	}
	else{
		$s1 = mssql_query("SELECT * FROM VLevelCabang WHERE substring(kode_so,1,7)='".substr($kodeso,0,7)."'", $conn);
		if(mssql_num_rows($s1) > 0){
			$r1 = mssql_fetch_array($s1);
			//mssql_free_result($s1x);
			echo"<small>$r1[uraian]</small>";
		}
	}	
		 echo"</td><td>";
	$jabatan = $row[jabatan2];
	if($jabatan == NULL){
	}
	else{
		$s3 = mssql_query("SELECT * FROM MstJabatan WHERE kode='".$jabatan."' ", $conn);
		if(mssql_num_rows($s3) > 0){
			$r3 = mssql_fetch_array($s3);	
			echo"<small>$r3[jabatan]</small>";
		}
	}	
	 echo"</td><td>";
	 // get nama fungsional
	 $fungsis = $row[fungsi2];
	 if(empty($fungsis)){
	 
	 }else{
	 		$sFn = mssql_query("SELECT * FROM MstFungsional WHERE kode='$fungsis'",$conn);
			$rFn = mssql_fetch_array($sFn);
			echo"<small>$rFn[nama]";			
	 }
	 echo"</td><td>";
	 // golongan
	 echo"<small>$row[gol2]";
	 echo"</td><td>";
	 // get status karyawan
	 $statkary = $row[stat_kar2];
	 if(empty($statkary)){
	 
	 }
	 else{
	 		$sSn = mssql_query("SELECT * FROM VStatusKaryawan WHERE kode='$statkary'",$conn);
			$rSn = mssql_fetch_array($sSn);
			echo"<small>$rSn[Nama]";
	 }
	 echo"</td><td>";
	 //edit
	 if($rpar[edit] == 1){
	 echo"
	 <a href='../form/frm_karir_ptsi.php?nik=$nik&amp;no=$row[No]&amp;op=edit'><img src='../images/b_edit.png' border=0></a>";
	 }
	 
	 echo"</td>
	 <td>";
	 
	 // hapus
	 if($rpar[hapus] == 1){
	 echo"<a href='#' onclick='hapus(\"karir_ptsi\",\"$nik\",\"$row[No]\")'><img src='../images/b_delete.png' border=0></a>";
	 }
	 echo"</td>
	<tr>
	";
}
?>
</table>
<?
}
elseif($show == "list_track_record")
{

	// hak akses
	$spar = mssql_query("SELECT * FROM VPrivUser WHERE username='".$_SESSION['user_login']."' AND nama_menu='track_record'",$conn);
	$rpar = mssql_fetch_array($spar);	

	if($HTTP_GET_VARS['appr'] == "yes" and $HTTP_GET_VARS['cat2'] == "appr_track_record"){

	mssql_query("WITH limit AS (SELECT ROW_NUMBER() OVER (ORDER BY NIK) as No, * FROM VTrackRecord WHERE NIK='$nik') UPDATE limit SET aktif='A' WHERE No='$no'",$conn);
	}
?>
<table width=100% class='table_indent2'>
   <tr>
    <td colspan="10" class="line_bottom">&nbsp;&nbsp;<b>HASIL PENCARIAN TRACK RECORD </b></td>
   </tr>
</table>
  <table width="100%" cellspacing="1" cellpadding="2">
   <?
   	$sNN	= mssql_query("SELECT * FROM Karyawan WHERE NIK='$nik'",$conn);
	$rNN	= mssql_fetch_array($sNN);
   ?>
   <tr>
    <td width="50">NIK</td>
	<td colspan="9"><?=$rNN[NIK]?></td>
   </tr>
   <tr>
    <td>Nama</td>
	<td colspan="9"><?=$rNN[Nama]?></td>
   </tr>
   <tr>
    <td colspan="10" align="right">
    <?
	// tambah
	if($rpar[tambah] == 1)
	{
	?>
    <input type="button" class="button" value="Tambah" onclick="Javascript:location.href='../form/frm_emp_track_record.php?nik=<?=$rNN[NIK]?>&amp;nama=<?=$rNN[Nama]?>'"/>
	<?
	}
    ?>
    </td>
   </tr>
   <tr>
    <td colspan="10"><hr noshade="noshade" size="-2" /></td>
   </tr>
   <tr class="headlist">
    <td width="1%">No.</td>
	<td>Start</td>
	<td>End</td>
	<td>Client</td>
	<td>Product</td>
	<td>Project</td>
	<td>Job Description</td>
    <td>Status</td>
	<td colspan="2" width="50">&nbsp;</td>
   </tr>
<?
$sql	= mssql_query("SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, CONVERT(CHAR(12), Track_start, 103) TrackStart, CONVERT(CHAR(12), Track_end, 103) TrackEnd, aktif, * FROM VTrackRecord WHERE NIK='$nik' ORDER BY seqno ",$conn);
while($row = mssql_fetch_array($sql)){
	echo"
	<tr class=contentlist>
	 <td align=right><a href='detail_karir_ptsi.php?nik=$nik&amp;no=$row[No]'>$row[No]</a></td>
	 <td><a href='show.php?show=detail_track_record&amp;nik=$nik&amp;no=$row[No]'>$row[TrackStart]</a></td>
	 <td><a href='show.php?show=detail_track_record&amp;nik=$nik&amp;no=$row[No]'>$row[TrackEnd]</a></td>	 
	 <td><a href='show.php?show=detail_track_record&amp;nik=$nik&amp;no=$row[No]'>$row[Client]</a></td>	 
	 <td><a href='show.php?show=detail_track_record&amp;nik=$nik&amp;no=$row[No]'>$row[Product]</a></td>	 
	 <td><a href='show.php?show=detail_track_record&amp;nik=$nik&amp;no=$row[No]'>$row[Project]</a></td>	 
	 <td><a href='show.php?show=detail_track_record&amp;nik=$nik&amp;no=$row[No]'>$row[Job_Desc]</a></td>
	 ";
	 
	 if($row[aktif] == NULL or $row[aktif] == 'A'){
	 	echo"<td style='color: blue;' align=center>Data diterima</td>";
	 }
	 else{
		echo"<td style='color: red;' align=center>Sedang dalam proses ...</td>";
	 }	 
	echo" 	 
	 <td align=center>";
	// approval
	if($rpar[approval] == 1){
	echo"
	 <a href='#' onclick='konfirm(\"appr_track_record\",\"".$row[No]."\",\"".$row[NIK]."\");'><img src='../images/apply.png' border=0 alt='Pertujuan/Approval' title='Persetujuan/Approval'></a>";
	}
	// edit
	if($rpar[edit] == 1){
	echo"
	 <a href='../form/frm_emp_track_record.php?nik=$nik&amp;no=$row[No]&amp;op=edit'><img src='../images/b_edit.png' border=0></a>";
	}
	// hapus
	if($rpar[hapus] == 1){
	echo"<a href='#' onclick='hapus(\"track_record\",\"$nik\",\"$row[No]\")'><img src='../images/b_delete.png' border=0></a>";
	}
	echo"</td>
	<tr>
	";
}
}
elseif($show == "list_sanksi")
	{
	
	$spar = mssql_query("SELECT * FROM VPrivUser WHERE username='".$_SESSION['user_login']."' AND nama_menu='sanksi'",$conn);
	$rpar = mssql_fetch_array($spar);	

?>
<table width=93% class='table_indent2'>
   <tr>
    <td colspan="10" class="line_bottom">&nbsp;&nbsp;<b>HASIL PENCARIAN SANKSI</b></td>
   </tr>
</table>
  <table width="100%" cellspacing="1" cellpadding="2"> 
   <?
   	$sNN	= mssql_query("SELECT * FROM Karyawan WHERE NIK='$nik'",$conn);
	$rNN	= mssql_fetch_array($sNN);
   ?>
   <tr>
    <td width="50">NIK</td>
	<td colspan="9"><?=$rNN[NIK]?></td>
   </tr>
   <tr>
    <td>Nama</td>
	<td colspan="9"><?=$rNN[Nama]?></td>
   </tr>
   <tr>
    <td colspan="10" align="right">
    <?
	// tambah
    if($rpar[tambah] == 1){
	?>
    <input type="button" class="button" value="Tambah" onclick="Javascript:location.href='../form/frm_emp_sanksi.php?nik=<?=$rNN[NIK]?>&amp;nama=<?=$rNN[Nama]?>'"/>
    <?
    }
	?>
    </td>
   </tr>
   <tr>
    <td colspan="10"><hr noshade="noshade" size="-2" /></td>
   </tr>
   <tr class="headlist">
    <td width="1%">No.</td>
	<td>No. Surat</td>
	<td>Tanggal Berlaku</td>
	<td>Tanggal Keluar</td>
    <td>Kategori Sanksi</td>
	<td colspan="2">&nbsp;</td>
   </tr>
<?
$sql	= mssql_query("SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM VSanksi WHERE NIK='$nik' ORDER BY No ASC ",$conn);
while($row = mssql_fetch_array($sql)){
	echo"
	<tr class=contentlist>
	 <td align=right><a href='show.php?show=detail_sanksi&amp;nik=$nik&amp;no=$row[No]'>$row[No]</a></td>
	 <td><a href='show.php?show=detail_sanksi&amp;nik=$nik&amp;no=$row[No]'>$row[no_surat]</a></td>
	 <td align=right><a href='show.php?show=detail_sanksi&amp;nik=$nik&amp;no=$row[No]'>$row[TglBerlaku]</a></td>
	 <td align=right><a href='show.php?show=detail_sanksi&amp;nik=$nik&amp;no=$row[No]'>$row[TglKeluar]</a></td>";	 
	 // get kategory sanksi
	 $gks = mssql_query("SELECT nama FROM VKatSanksi WHERE kode='$row[category]'",$conn);
	 $rks = mssql_fetch_array($gks);
	 echo"<td>$rks[nama]</td>";
	 //<td><a href='show.php?show=detail_sanksi&amp;nik=$nik&amp;no=$row[No]'>";
	 //$slokasi = mssql_query("SELECT * FROM MstLokasi WHERE kode_lokasi='$row[lokasi]'",$conn);
	 //$rlokasi = mssql_fetch_array($slokasi);
	 //echo"$rlokasi[distrik] - $rlokasi[propinsi]";
	 echo"</a></td>	 
	 <td><a href='show.php?show=detail_sanksi&amp;nik=$nik&amp;no=$row[No]'>";
	 /*
       	if(empty($row[kode_so1])){
			$kodeso= $row[kode_so2];
		}
		else{
			$kodeso= $row[kode_so1];
		}
	 
	 $sUK = mssql_query("SELECT * FROM MstSO WHERE kode_so='$row[kode_so]'",$conn);
	 $rUK = mssql_fetch_array($sUK);
	 //echo"$rUK[AreaCode] - $rUK[uraian]
			// get divisi
			$gdw = mssql_query("SELECT * FROM MstSO WHERE kode_so='$rUK[kode_so]'",$conn);
			$rdw = mssql_fetch_array($gdw);
			//echo"$rdw[uraian]";
			
			$level1	= substr($rdw[kode_so],0,2); // direktorat
			$level2 = substr($rdw[kode_so],2,2); // koordinator
			$level3 = substr($rdw[kode_so],4,3); // cabang biro 
			$level4 = substr($rdw[kode_so],7,3); // bagian
			$level5 = substr($rdw[kode_so],10,2); //seksi
			
			$sql4 = mssql_query("select * from vlevelcabang where substring(kode_so,1,7)='".$level1.$level2.$level3."' order by kode_so",$conn);
			if(mssql_num_rows($sql4) > 0){
			$row4 = mssql_fetch_array($sql4);
				echo $row4[uraian];
			}
	 echo"<td>";
	 */
	 //edit
	 if($rpar[edit] == 1){
	 echo"
	 <a href='../form/frm_emp_sanksi.php?nik=$nik&amp;no=$row[No]&amp;op=edit'><img src='../images/b_edit.png' border=0></a>";
	 }
	 echo"</td>
	 <td>";
	 
	 //hapus
	 if($rpar[hapus] == 1){
	 echo"
	 <a href='#' onclick='hapus(\"sanksi\",\"$nik\",\"$row[No]\")'><img src='../images/b_delete.png' border=0></a>";
	 }
	 echo"</td>
	</tr>
	";
	}
	echo"</table>";
}
elseif($show == "list_tugas")
	{
	// hak akses
	$spar = mssql_query("SELECT * FROM VPrivUser WHERE username='".$_SESSION['user_login']."' AND nama_menu='penugasan'",$conn);
	$rpar = mssql_fetch_array($spar);	

?>
  <table width=100% class='table_indent2' cellspacing="1" cellpadding="2">
   <tr>
    <td colspan="10"><b>Daftar PENUGASAN di PT. SURVEYOR INDONESIA</b><br /><br /></td>
   </tr>
   <?
   	$sNN	= mssql_query("SELECT * FROM Karyawan WHERE NIK='$nik'",$conn);
	$rNN	= mssql_fetch_array($sNN);
   ?>
   <tr>
    <td width="50">NIK</td>
	<td colspan="9"><?=$rNN[NIK]?></td>
   </tr>
   <tr>
    <td>Nama</td>
	<td colspan="9"><?=$rNN[Nama]?></td>
   </tr>
   <tr>
    <td colspan="10" align="right">
    <?
    if($rpar[tambah] == 1){
	?>
    <input type="button" class="button" value="Tambah" onclick="Javascript:location.href='../form/frm_emp_penugasan.php?nik=<?=$rNN[NIK]?>&amp;nama=<?=$rNN[Nama]?>'"/>
    <?
    }
	?>
    </td>
   </tr>
   <tr>
    <td colspan="10"><hr noshade="noshade" size="-2" /></td>
   </tr>
	<tr class=headlist>
	 <td width="2">No.</td>
	 <td>No. Surat</td>
	 <td>Tanggal Surat</td>
	 <td>Dari</td>
	 <td>Sampai</td>
	 <td>Tujuan</td>
	 <td>Keperluan</td>
	 <td colspan="2">&nbsp;</td>
	</tr>
<?
$sql	= mssql_query("SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM VPenugasan WHERE NIK='$nik' ORDER BY No ASC ",$conn);
while($row = mssql_fetch_array($sql)){
	echo"
	<tr class=contentlist>
	 <td align=right><a href='show.php?show=detail_tugas&amp;nik=$nik&amp;no=$row[No]'>$row[No]</a></td>
	 <td><a href='show.php?show=detail_tugas&amp;nik=$nik&amp;no=$row[No]'>$row[no_surat]</a></td>
	 <td align=right><a href='show.php?show=detail_tugas&amp;nik=$nik&amp;no=$row[No]'>$row[TglSurat]</a></td>
	 <td align=right><a href='show.php?show=detail_tugas&amp;nik=$nik&amp;no=$row[No]'>$row[TglDari]</a></td>
	 <td align=right><a href='show.php?show=detail_tugas&amp;nik=$nik&amp;no=$row[No]'>$row[TglSampai]</a></td>
	 <td><a href='show.php?show=detail_tugas&amp;nik=$nik&amp;no=$row[No]'>$row[tujuan]</a></td>	 
	 <td><a href='show.php?show=detail_tugas&amp;nik=$nik&amp;no=$row[No]'>$row[keperluan]</a></td>	 
	 <td>";
	 // edit
	 if($rpar[edit] == 1){
	 echo"<a href='../form/frm_emp_penugasan.php?nik=$nik&amp;no=$row[No]&amp;op=edit'><img src='../images/b_edit.png' border=0></a>";
	 }
	 echo"	
	 </td>
	 <td>";
	 // hapus
	 if($rpar[hapus] == 1){
	 echo"<a href='#' onclick='hapus(\"penugasan\",\"$nik\",\"$row[No]\")'><img src='../images/b_delete.png' border=0></a>";
	 }
	 echo"</td>
	<tr>
	";
	}
	echo'</table>';

}
// daftar penilaian
elseif($show == "list_nilai")
	{
?>
  <table width='100%' class='table_indent2' cellspacing="1" cellpadding="2">
   <tr>
    <td colspan="10" class="line_bottom">&nbsp;&nbsp;<b>DAFTAR PENILAIAN KARYAWAN</b></td>
   </tr>
   <?
    // menampilkan nama/nik
	$sN	= mssql_query("SELECT NIK, Nama FROM Karyawan WHERE NIK='$nik'",$conn);
	$rN = mssql_fetch_array($sN);
// get data from karir ptsi
$skarptsi = mssql_query("SELECT * FROM VKarirPtsi WHERE NIK='$nik' ORDER BY seqno DESC",$conn);
$rkarptsi = mssql_fetch_array($skarptsi);

if(empty($rkarptsi[kode_so1])){
	$kodeso = $rkarptsi[kode_so2];
}
else{
	$kodeso = $rkarptsi[kode_so1];
}

if(empty($kodeso)){
}
else{

			// get divisi
			$gdw = mssql_query("SELECT * FROM MstSO WHERE kode_so='$kodeso'",$conn);
			$rdw = mssql_fetch_array($gdw);
			//echo"$rdw[uraian]";
			
			$level1	= substr($rdw[kode_so],0,2); // direktorat
			$level2 = substr($rdw[kode_so],2,2); // koordinator
			$level3 = substr($rdw[kode_so],4,3); // cabang biro 
			$level4 = substr($rdw[kode_so],7,3); // bagian
			$level5 = substr($rdw[kode_so],10,2); //seksi
			
			$sql4 = mssql_query("select * from vlevelcabang where substring(kode_so,1,7)='".$level1.$level2.$level3."' order by kode_so",$conn);
			if(mssql_num_rows($sql4) > 0){
			$row4 = mssql_fetch_array($sql4);
				$divisi = $row4[uraian];
			}
}
   ?>
	<tr>
	 <td colspan="10">
	  <table style="position:relative; left:25px;">
	   <tr>
	    <td>NIK:</td>
		<td><?=$rN[NIK]?></td>
		<td colspan="25">&nbsp;</td>
		<td>Jabatan:</td>
		<td>
  <?
  	if(empty($rkarptsi[jabatan1])){
		$jab 	= $rkarptsi[jabatan2];
		if(empty($jab)){
		}
		else{
			$sjab 	= mssql_query("SELECT * FROM MstJabatan WHERE kode='$jab'");
			if(mssql_num_rows($sjab) > 0){
				$rjab = mssql_fetch_array($sjab);
				echo"$rjab[jabatan]";
			}
		}
	}
	else{
		$jab 	= $rkarptsi[jabatan1];
		if(empty($jab)){
		}
		else{
			$sjab 	= mssql_query("SELECT * FROM MstJabatan WHERE kode='$jab'");
			if(mssql_num_rows($sjab) > 0){
				$rjab = mssql_fetch_array($sjab);
				echo"$rjab[jabatan]";
			}
		}
	}
  ?>
        </td>
	   </tr>
	   <tr>
	    <td>Nama:</td>
		<td><?=$rN[Nama]?></td>
		<td colspan="25">&nbsp;</td>
		<td>Unit Kerja/Divisi/Biro/Cabang:</td>
		<td><?=$divisi?></td>		
	   </tr>
	  </table>
	 </td>
	</tr>
   <tr>
    <td colspan="4">&nbsp;</td>
    <td align="right"><input type="button" value="Kembali" onclick="Javascript:history.back()" class="button" /></td>
   </tr>
   <tr>
    <td colspan="5">
    <?
	if($HTTP_GET_VARS['showpop'] == ""){
      $sn	= mssql_query("SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM S_LP WHERE penilai_atasan1='$nik' OR penilai_atasan2='$nik' OR penilai_peers1='$nik' OR penilai_peers2='$nik' OR penilai_peers3='$nik' OR penilai_adum='$nik'");
	  if(mssql_num_rows($sn) > 0){
	?>
     <fieldset>
      <legend>Penilaian Terhadap Pegawai Lain</legend>
      <table width="100%">
       <tr class="headlist">
        <td>No.</td>
        <td>Periode</td>
        <td>NIK</td>
        <td>Nama</td>
        <td>Divisi</td>
        <td>Jabatan</td>
        <td>Jenis Penilai</td>
        <td>Status</td>
       </tr>
       <?
	   while($rn	= mssql_fetch_array($sn)){
	   echo"<tr class='contentlist'>
	   <td align=right>$rn[No]</td>
	   <td>$rn[periode]</td>
	   <td>$rn[NIK]</td>
	   ";
		// get data from karir ptsi
		$skarptsi = mssql_query("SELECT * FROM VLatestKarir WHERE NIK='$rn[NIK]'",$conn);
		$rkarptsi = mssql_fetch_array($skarptsi);
		
		$scb = mssql_query("SELECT uraian FROM VLevelCabang WHERE substring(kode_so,1,7)='".substr($rkarptsi[kode_so2],0,7)."'",$conn);
		$rcb = mssql_fetch_array($scb);	
		
		if(!empty($rkarptsi[jabatan2])){
			$jab 	= $rkarptsi[jabatan2];
			if(empty($jab)){
			}
			else{
				$sjab 	= mssql_query("SELECT * FROM MstJabatan WHERE kode='$jab'");
				if(mssql_num_rows($sjab) > 0){
					$rjab = mssql_fetch_array($sjab);
				}
			}
		}
		
	   if($rn[penilai_atasan1] == $nik){
			$TT = "sebagai Atasan";
			$tipe = "atasan";
	   }
	   elseif($rn[penilai_atasan2] == $nik){
			$TT = "sebagai Atasan";
			$tipe = "atasan";
	   }
	   elseif($rn[penilai_peers1] == $nik){
			$TT = "sebagai Peers (Rekan Kerja)";
			$tipe = "peers";
	   }
	   elseif($rn[penilai_peers2] == $nik){
			$TT = "sebagai Peers (Rekan Kerja)";
			$tipe = "peers";
	   }
	   elseif($rn[penilai_peers3] == $nik){
			$TT = "sebagai Peers (Rekan Kerja)";
			$tipe = "peers";
	   }
	   elseif($rn[penilai_adum] == $nik){
			$TT = "sebagai ADUM";
			$tipe = "adum";
	   }

		echo"
		<td><a href='../form/frm_emp_penilaian.php?nik=$rn[NIK]&amp;tahun=$rn[periode]&amp;tipe=$tipe'>$rkarptsi[Nama]</a></td>
		<td><a href='../form/frm_emp_penilaian.php?nik=$rn[NIK]&amp;tahun=$rn[periode]&amp;tipe=$tipe'>$rcb[uraian]</a></td>
		<td><a href='../form/frm_emp_penilaian.php?nik=$rn[NIK]&amp;tahun=$rn[periode]&amp;tipe=$tipe'>$rjab[jabatan]</a></td>
		";
		 echo"
		 <td>$TT</td>
		 <td>
		 ";  
		 // get status penilaian
		 $stn = mssql_query("SELECT * FROM S_LP_Detail WHERE nama_penilai='$nik' AND periode='$rn[periode]' AND NIK='$rn[NIK]'",$conn);
		 if(mssql_num_rows($stn) > 0){
		 	echo"Sudah";
		 }
		 else{
		 	echo"<span style='color: red;'>Belum</span>";
		 }
		 echo"</td>";
	   }
	   ?>
      </table>
     </fieldset>
     <?
     }
	 echo"<br><br>";
	 //else{
      $sn2	= mssql_query("SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM S_LP WHERE NIK='$nik'");
	  if(mssql_num_rows($sn2) > 0){
	?>
     <fieldset>
      <legend>Penilaian Pegawai Sendiri</legend>
      <table width="100%">
		<tr class="headlist">
         <td width="2%">No.</td>
         <td width="10%">Periode</td>
         <td>Status</td>
        </tr>
        <?
        	$snp = mssql_query("SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM S_LP WHERE NIK='$nik'",$conn);
			while($rnp = mssql_fetch_array($snp)){
				echo"
				<tr class=contentlist>
				 <td align=right>$rnp[No]</td>
				 <td>$rnp[periode]</td>
				 <td>";
				 // get status
				 	$ssnp = mssql_query("SELECT *, CONVERT(CHAR(12), created, 103) tanggal FROM S_LP_Detail WHERE NIK='$rnp[NIK]' AND nama_penilai='$rnp[NIK]' AND periode='$rnp[periode]' AND kategori_penilai='pegawai'",$conn);
					if(mssql_num_rows($ssnp) > 0){
						$rsnp = mssql_fetch_array($ssnp);
						echo"Sudah pada tanggal $rsnp[tanggal]";
					}
					else{
						echo"<span style='color: red;'>Belum</span>, <a href='../form/frm_emp_penilaian.php?nik=$nik&amp;tahun=$rnp[periode]&amp;tipe=pegawai'>Silahkan mengisi ...</a>";
					}
				 echo"
				 </td>
				</tr>
				";
			}
		?>
      </table>
     </fieldset>
     <?
	 //}
	 }
	 
	 }
	 
	 if($HTTP_GET_VARS['showpop'] == "detail"){
	 //////////////////////////////////////// 
	 //else{
	  $sn	= mssql_query("SELECT ROW_NUMBER() OVER (ORDER BY NIK) AS No, * FROM S_LP WHERE NIK='$nik'");
  		if(mssql_num_rows($sn) > 0){
	 ?>
     <fieldset>
      <legend>Penilaian Pegawai Yang Bersangkutan</legend>
      <table>
       <tr class="headlist">
        <td>No.</td>
        <td width="100">Periode</td>
        <td width="200">Jenis Penilai</td>
        <td width="100">Status</td>
       </tr>
       <?
	   while($rn	= mssql_fetch_array($sn)){
	   echo"<tr class='contentlist'>
	   <td>$rn[No]</td>
	   <td>$rn[periode]</td>
	   ";
		$tipe = "pegawai";
		 echo"
		 <td>$tipe</td>
		 <td>
		 ";  
		 // get status penilaian
		 $stn = mssql_query("SELECT * FROM S_LP_Detail WHERE nama_penilai='$nik' AND periode='$rn[periode]'",$conn);
		 if(mssql_num_rows($stn) > 0){
		 	echo"Sudah";
		 }
		 else{
		 	echo"<span style='color: red;'>Belum</span>";
		 }
		 echo"</td>";
	   }
	   ?>
      </table>
     </fieldset>
     <?
	 }
	 else{
	 		echo"<center><i>Belum ada penilaian untuk Anda ...</i></center>";
	 	}
	 }
	 // end if
	 }
	 ?>
    </td>
   </tr>
	
 </table>
<?
//}	
?>
<table width=93% class='table_indent2'>
</table>

<?
echo"</div>
	  </td>
	   </tr>
	    </table>
";
include("../menu.php");
?>
